<template>
  <div id="customerContribute">
    <h1 class="con-right-title">
      C端分享回流贡献
    </h1>
    <topSearch :form-inline="formInline" @toSearch="toSearch"></topSearch>
    <div class="table-conBtn">
      <freshCom @searchList="searchList"></freshCom>
    </div>
    <!-- 表格部分 -->
    <el-table
      :data="tableData"
      v-loading="loading"
      style="width: 100%"
      ref="table"
    >
      <el-table-column type="index" label="序号" width="50">
        <template slot-scope="scope">
          {{
            scope.$index
              | filterPage(searchParams.pageNum, searchParams.pageSize)
          }}
        </template>
      </el-table-column>
      <el-table-column
        prop="dpAccount"
        label="大鹏号"
        min-width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="firstShareCount"
        label="1次分享次数"
        min-width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="secondShareCount"
        label="2次分享次数"
        min-width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="registerCount"
        label="回流新增用户数"
        min-width="150"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="intakeCount"
        label="回流入量用户数"
        min-width="150"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="recallCount"
        label="回流召回用户数"
        min-width="150"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="uvCount"
        label="回流UV"
        min-width="100"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="pvCount"
        label="回流PV"
        min-width="100"
        align="center"
      >
      </el-table-column>
    </el-table>
    <pageCom
      :searchParams="searchParams"
      :total="total"
      @searchList="searchList"
    ></pageCom>
  </div>
</template>
<script>
import { getCustomerList } from '@/api/shareBackFlow/customer'
import { filterImageMixins } from '@/mixins/filterImage'
import { saveScrollMixins } from '@/mixins/saveScroll'
import { getDay } from '@/utils/yesterday'
import topSearch from '@component/customerContribute/topSearch' // 上部搜索条件

export default {
  name: 'contribute',
  msg: 'C端分享回流贡献',
  mixins: [filterImageMixins, saveScrollMixins],
  components: {
    topSearch
  },
  data() {
    return {
      loading: false,
      tableData: [],
      total: 0,
      searchParams: {
        pageNum: 1, // 当前页数
        pageSize: 10 // 页面显示条数
      },
      formInline: {
        dpAccount: '',
        statisticDate: ''
      }
    }
  },
  created() {
    this.formInline.statisticDate = getDay(-1, '-')
  },
  mounted() {
    this.searchList()
  },
  methods: {
    toSearch() {
      this.searchParams.pageNum = 1
      this.searchList()
    },
    /* 换页 */
    changePage(page) {
      this.searchParams.pageNum = page
      this.searchList()
    },
    /* 获取列表 */
    searchList() {
      this.loading = true
      let params = {
        ...this.searchParams,
        ...this.formInline
      }
      getCustomerList(
        params,
        (response) => {
          this.loading = false
          this.tableData = response.rows
          this.total = response.total
        },
        (response) => {
          this.loading = false
          this.$message({
            message: response.message,
            type: 'warning'
          })
        }
      )
    },
    refreshList() {
      this.searchParams.pageNum = 1
      this.searchList()
    }
  }
}
</script>
<style lang="less">
#customerContribute {
  .data-input .el-input__inner {
    padding-left: 30px !important;
  }
  .img-box {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;

    .img-inner-box {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
      text-align: center;

      .el-image {
        width: 100%;
        height: 100%;
      }

      img {
        max-width: 100%;
        max-height: 100%;
        cursor: pointer;
      }
    }

    .num {
      position: absolute;
      display: block;
      bottom: 0;
      right: 0;
      width: 16px;
      height: 16px;
      background: rgba(0, 0, 0, 0.7);
      color: #fff;
      font-size: 12px;
      text-align: center;
      line-height: 16px;
    }
  }
}
</style>
